<?php

namespace api\channel\movie;

use api\channel\ExtendChannleBase;
use app\common\facade\supplier\Supplier;
use app\model\BaseSupplier;
use app\model\MovieOrder;
use Carbon\Carbon;
use think\Exception;

class MovieSelf extends ExtendChannleBase
{
    public function __construct()
    {
        /**
         * 赋值
         */
        $this->supplierInfo = BaseSupplier::query()
            ->where('code','taototo')
            ->find();

        if (empty($this->supplierInfo)){
            throw new Exception('淘兔兔的供应商不存在');
        }



    }

    public function orders($params)
    {
        $page = $params['page'];

        //后面再优化分页： 和更新数据 限制条数
        $data = MovieOrder::query()
            ->where('status',MovieOrder::STATUS_PAY)
            ->where('created_at','>',Carbon::now()->subHours(48)->format('Y-m-d H:i:s'))
            ->where('settle_type',SETTLE_TYPE_PROFIT)
            ->page($page)->select()->toArray();

        $res['data'] = $data;

        return $res;
    }

}